<script lang='ts' setup>
import { ref, reactive } from 'vue';
import { useRouter } from 'vue-router'
import JxudpDataSourceForm from './component/jxudp-data-source-form.vue';
import { redirectPath } from '/@/utils/router-kit';
import { JxudpDataSourceListUrl, JxudpDataSourceEditUrl } from '/@/views/org/mapping.json'
const router = useRouter();
const JxudpDataSourceFormRef = ref();
const JxudpDataSourceFormState = reactive({
    dataSourceId: router.currentRoute.value.params.id as string,
    onBackClick: () => router.push({ path: JxudpDataSourceListUrl }),
    saveForm: () => JxudpDataSourceFormRef.value.save(),
    /**新增成功 跳转页面 */
    onAddFormSuccess: (formData: any) => {
        redirectPath(JxudpDataSourceEditUrl + formData.dataSourceId)
    }
})
</script>
<template>
    <jxtech-basic-header :breadcrumbMappingUrl="JxudpDataSourceListUrl">
        <template #extra>
            <jxtech-save-button @click="JxudpDataSourceFormState.saveForm"></jxtech-save-button>
            <jxtech-back-button @click="JxudpDataSourceFormState.onBackClick"></jxtech-back-button>
        </template>
    </jxtech-basic-header>
    <jxudp-data-source-form
        ref="JxudpDataSourceFormRef"
        :data-source-id="JxudpDataSourceFormState.dataSourceId"
        @add-success="JxudpDataSourceFormState.onAddFormSuccess"
    ></jxudp-data-source-form>
</template>